<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>角色</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.4/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <blockquote class="layui-elem-quote layui-text">
            在此可以编辑
        </blockquote>

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>编辑产品</legend>
        </fieldset>

        <form class="layui-form">

            <input type="hidden" name="goods_id" value="{{$data['id']}}">
            <div class="layui-form-item">
                <label class="layui-form-label">产品标题</label>
                <div class="layui-input-inline">
                    <input type="text" name="title" lay-verify="title"  required   value="{{$data['title']}}" autocomplete="off"
                           placeholder="请输入标题"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">分类</label>
                    <div class="layui-input-inline">
                        <select name="type_id">
                            <option value="">分类</option>
                            @foreach($type as $item)
                                <option @if($data['type_id'] == $item->id)    selected
                                        @endif value="{{$item->id}}">{{$item->title}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">公告开始日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="publicity"       id="publicity" lay-verify="required" value="{{$data['publicity']}}" autocomplete="off"
                           placeholder="公告开始日期"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">公告期限/天</label>
                <div class="layui-input-inline">
                    <input type="text" name="publicity_day"         lay-verify="required" value="{{$data['publicity_day']}}" autocomplete="off"
                           placeholder="公告期限"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">拍卖开始日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="auction"        id="auction" lay-verify="required" value="{{$data['auction']}}" autocomplete="off"
                           placeholder="拍卖开始日期"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">竞价周期/天</label>
                <div class="layui-input-inline">
                    <input type="text" name="auction_day"      lay-verify="required" value="{{$data['auction_day']}}" autocomplete="off"
                           placeholder="竞价周期"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">延时周期/分钟</label>
                <div class="layui-input-inline">
                    <input type="number" name="delay_time"     lay-verify="required" value="{{$data['delay_time']}}" autocomplete="off"
                           placeholder="延时周期"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">债权金额</label>
                <div class="layui-input-inline">
                    <input type="number" name="debt"     lay-verify="required" value="{{$data['debt']}}" autocomplete="off"
                           placeholder="债权金额"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">债权到期日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="debt_date"    id="debt_date"   lay-verify="required" value="{{$data['debt_date']}}" autocomplete="off"
                           placeholder="债权到期日期"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">起拍价</label>
                <div class="layui-input-inline">
                    <input type="number" name="start_price"    lay-verify="required" value="{{$data['start_price']}}" autocomplete="off"
                           placeholder="起拍价"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">加价幅度</label>
                <div class="layui-input-inline">
                    <input type="number" name="scope_price"     lay-verify="title" value="{{$data['scope_price']}}" autocomplete="off"
                           placeholder="加价幅度"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">保证金</label>
                <div class="layui-input-inline">
                    <input type="number" name="price" lay-verify="title"   value="{{$data['price']}}" autocomplete="off"
                           placeholder="保证金"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">保留价</label>
                <div class="layui-input-inline">
                    <input type="number" name="reserve_price"   lay-verify="title" value="{{$data['reserve_price']}}" autocomplete="off"
                           placeholder="保留价"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">优先购买人</label>
                <div class="layui-input-inline">
                    <input type="text" name="reserve_price"   lay-verify="title" value="{{$data['reserve_price']}}" autocomplete="off"
                           placeholder="优先购买人"
                           class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">产品审核</label>
                    <div class="layui-input-inline">
                        <select name="status" lay-verify="required" lay-filter="goods_status"
                                lay-search="">
                            <option value="1">待审核</option>
                            <option value="2">通过</option>
                            <option value="3">拒绝</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item  message" style="display: none">
                <label class="layui-form-label">拒绝原因</label>
                <textarea id="message"     placeholder="拒绝原因"  class="layui-textarea"  required name="message" > {{$data['message']}}</textarea>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">产品介绍</label>
                <textarea id="introduce"     placeholder="产品介绍"    name="introduce" > {{$detail['introduce']}}</textarea>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">竞买公告</label>
                <textarea id="notice"     placeholder="竞买公告"   name="notice" > {{$detail['notice']}}</textarea>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">竞买须知</label>
                <textarea id="instructions"     placeholder="竞买须知"  required name="instructions" > {{$detail['instructions']}}</textarea>
            </div>



            <div id="test12" class="demo-tree-more"></div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                </div>
            </div>
        </form>

    </div>
</div>
{{--6624+8646+1251+--}}
<script src="/lib/layui-v2.5.4/layui.js" charset="utf-8"></script>
<script src="/js/jquery-3.4.1.min.js" charset="utf-8"></script>
<script>

    layui.use(['form', 'layedit', 'laydate'], function () {

        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#publicity',
            type: 'datetime'
        });
        laydate.render({
            elem: '#auction',
            type: 'datetime'
        });
        laydate.render({
            elem: '#debt_date',
            type: 'datetime'
        });
        // auction
        //创建一个编辑器
        var notice = layedit.build('notice');
        var instructions = layedit.build('instructions');
        var introduce = layedit.build('introduce');
        form.on('select(filter)', function(data){});

        form.on('select(goods_status)', function (data) {
           var  val =data.value;
            if(val == 3){
                $('.message').css('display', 'block')

            }else{
                $('.message').css('display', 'none')
            }

        })

        //是否外部车辆
        form.on('select(in_out)', function (data) {
            alert(231)
        })

        //监听提交
        var url = '/admin/goods/save';
        form.on('submit(demo1)', function (data) {
            var formData = data.field;
            data.field.notice =layedit.getContent(notice);
            data.field.instructions =layedit.getContent(instructions);
            data.field.introduce =layedit.getContent(introduce);

            // console.log(formData);
            // return false;
            $.ajax({
                url: url,
                data: formData,
                method: 'post',
                headers: {
                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
                },
                success: function (resp, status, xhr) {
                    if (xhr.status == 200) {
                        location.href = '/admin/goods/index';
                    }
                },
                error: function (re) {
                    layer.msg(re.responseJSON.msg, {icon: 2});

                }
            })


            return false;
            return false;
        });

    });
</script>

</body>
</html>